package com.applink.sell_proof.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ScrollView;

public class MyScrollView extends ScrollView{
	
	private boolean mFreezeTouch = false;
	public MyScrollView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	
	public MyScrollView(Context context, AttributeSet attrs){
		super(context, attrs);
	}
	
	public MyScrollView(Context context) {
		super(context);
	}
	/*
	@Override
	protected void onScrollChanged(int l, int t, int oldl, int oldt) {
	        View linearLayout = getChildAt(getChildCount()-1);
	        int diff = linearLayout.getBottom() - (getHeight() + getScrollY());
	        Log.e(VIEW_LOG_TAG, "currrent vertical " + t);
	        Log.e(VIEW_LOG_TAG, "old vertical " + oldt);
	        if(diff <= 0) {
	        	Log.e(VIEW_LOG_TAG, "reach bottom freeze touch");
	        	mFreezeTouch = true;
	        }
	        super.onScrollChanged(l, t, oldl, oldt);
	}*/
	
	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		if(mFreezeTouch == true) {
			return false;
		} else {
			return super.onTouchEvent(ev);
		}
	}
	
	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		if(mFreezeTouch == true) {
			return false;
		} else {
			return super.onInterceptTouchEvent(ev);
		}
	}

	public void toggleFreezeTouch() {
		this.mFreezeTouch = !mFreezeTouch;
	}
	
}
